import Vue from 'vue'
import VueRouter from 'vue-router'
import Login from '../components/Login.vue'
import zhuce from '../components/zhuce.vue'
import home from '../components/home.vue'
import Welcome from '../components/Welcome.vue'
import Users from '../components/admin/Users.vue'
import book from '../components/admin/book.vue'
import reader from '../components/admin/reader.vue'
import gonggao from '../components/admin/gonggao.vue'
import admin from '../components/admin/admin.vue'
import bookchars from '../components/echarts/bookchars.vue'
import Main from '../components/Main.vue'
import Head from '../components/zhuye/Head.vue'
import Gg from '../components/zhuye/gonggao.vue'
import opinion from '../components/zhuye/opinion.vue'
import Pcenter from '../components/zhuye/Pcenter.vue'
import grzl from '../components/user/grzl.vue'
import his from '../components/user/hisorty.vue'
import bchars from '../components/echarts/borrowchars.vue'
Vue.use(VueRouter)
const routes = [{
		path: '/Login',
		component: Login
	}, {
		path: '/',
		redirect: '/Main'
	}, {
		path: '/Main',
		component: Main,
		redirect:'/Head',
		children:[{
			path:'/Head',
			component:Head
		},{
			path:'/Gg',
			component:Gg
		},{
			path:'/opinion',
			component:opinion
		},{
			path:'/Pcenter',
			component:Pcenter,
			redirect:'/grzl',
			children:[{
				path:'/grzl',
				component:grzl
			},{
				path:'/his',
				component:his
			}]
		}]

	}, {
		path: '/home',
		component: home,
		redirect: '/book',
		children: [{
				path: '/users',
				component: Users
			}, {
				path: '/book',
				component: book
			}, {
				path: '/reader',
				component: reader
			}, {
				path: '/gonggao',
				component: gonggao
			}, {
				path: '/admin',
				component: admin
			},
			{
				path: '/bookchars',
				component: bookchars
			},
			{
				path:'/bchar',
				component:bchars
			}
		]
	},{
		path:'/zhuce',
		component:zhuce
	}

]

const router = new VueRouter({
	routes
})
//挂载路由导航守卫

router.beforeEach((to, from, next) => {
	// to 将要访问的位置
	// form从哪里跳转来的
	// next 表示放行
	// if (to.path === '/Login') return next();
	// 获取token
	// const tokens = window.sessionStorage.getItem('token');
	// if (!tokens) return next('/Login');
	next();
})
export default router
